package com.example.costumview.customview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;

public class AnimProgressive1View extends View {
    private static final String TAG = "AnimProgressiveView";
    private Paint mPaint;


    public AnimProgressive1View(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
       init();
    }

    private void init() {
        mPaint = new Paint();
        mPaint.setColor(Color.RED);
        mPaint.setStrokeWidth(8);
        mPaint.setStyle(Paint.Style.STROKE);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.translate(50,50);

        Path path=new Path();
        path.moveTo(0,0);
        path.lineTo(0,100);
        path.lineTo(100,100);
        path.lineTo(100,0);

        PathMeasure measure1=new PathMeasure(path,false);
        PathMeasure measure2=new PathMeasure(path,true);

        Log.e(TAG, "forceClosed=false: "+measure1.getLength() );
        Log.e(TAG, "forceClosed=true: "+measure2.getLength() );

        canvas.drawPath(path,mPaint);
    }
}
